package org.nci.uRunking.dao;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.persistence.criteria.From;

import org.hibernate.SessionFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.orm.hibernate3.HibernateTemplate;

public class test {
	@Resource(name="sessionFactory")
	private static SessionFactory sessionFactory;
	
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

    public int query()
    {
        HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
        ArrayList list = (ArrayList) hibernateTemplate.find("from user");
        return list.size();
    }
	public static void main(String[] args) {
        
        
        ApplicationContext context = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/classes/org/nci/confi/applicationContext.xml");
        sessionFactory = (SessionFactory)context.getBean("sessionFactory");
        List object = sessionFactory.openSession().createSQLQuery("select * from user").list();
        for (Object object2 : object) {
            Object[] obj = (Object[]) object2;
            for (int i = 0; i < obj.length; i++) {
            	System.out.println("size--"+obj[i]);
			}
            
		}


	}

}
